--[[
				 _______         _ _             _      _ _                          
				|__   __|       | | |           | |    (_) |                         
				   | |_ __ _   _| | | ___ _ __  | |     _| |__  _ __ __ _ _ __ _   _ 
				   | | '__| | | | | |/ _ \ '__| | |    | | '_ \| '__/ _` | '__| | | |
				   | | |  | |_| | | |  __/ |    | |____| | |_) | | | (_| | |  | |_| |
				   |_|_|   \__, |_|_|\___|_|    |______|_|_.__/|_|  \__,_|_|   \__, |
				            __/ |                                               __/ |
	Author:		           |___/                                               |___/ 

	version: 1.0.0
--]]

--[[
			 ______                _   _                 
			|  ____|              | | (_)                
			| |__ _   _ _ __   ___| |_ _  ___  _ __  ___ 
			|  __| | | | '_ \ / __| __| |/ _ \| '_ \/ __|
			| |  | |_| | | | | (__| |_| | (_) | | | \__ \
			|_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
--]]

function avoidks()
	if maround(5) < 1 then
		settargeting("off")
	else
		if (paround(7) == 0) or (target.id ~= 0) or 	((maround(1) > 0) and (paround(4) == 0)) then
			settargeting("on")
			wait(100)
		else
			settargeting("off")
			wait(100)
		end
	end
end

function withdraw(total, depositgold, safebank)
	if not total or total == 0 then
		return true
	end

	say("hi")
	wait(1500, 2500)
	if depositgold == true then
		npcsay("deposit all")
		wait(300, 500)
		npcsay("yes")
	end

	wait(300, 500)
	if total > 0 then
		npcsay("withdraw "..total)
		wait(300, 500)
		npcsay("yes")
	end

	wait(300, 500)
	npcsay("balance")
	wait(300, 500)

	if safebank == true then
		wait(1500, 2000)
		local msgs = getmessages("NPCs")
		local msg = msgs.count-1

		for i = 1, msg do
			if msgs[i].text:find("There is not enough gold on your account.") then
				wait(1000, 2000)
				setcavebot("off")
				wait(1000, 2000)
				closetibia()
			end
		end
	end

	return true
end

